using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;

public class OnEnnemyDefeated : UnityEvent<Ennemy> { }

public enum EnnemyType
{
    MinionBasis,
    MinionMasked,
    MinionMaster,
    FinalBoss
}

public class Ennemy : Entity {

    protected Dave m_dave;
    protected bool m_canAttack;
    public OnEnnemyDefeated onEnnemyDefeated = new OnEnnemyDefeated();
    RoomManager m_room;

    [SerializeField]
    protected EnnemyType m_type;

    public EnnemyType TypeEnnemy {  get { return m_type; } }

    [SerializeField]
    protected float m_speed = 15;


    protected override void Start()
    {
        base.Start();
        m_team = 1;
        m_dave = FindObjectOfType<Dave>();
        m_canAttack = true;
    }

    IEnumerator WaitAndDisapear()
    {
        yield return new WaitForSeconds(10);
        Destroy(this.gameObject);
    }

    protected override void defeated()
    {
        base.defeated();
       
        StartCoroutine(WaitAndDisapear());
        onEnnemyDefeated.Invoke(this);      
    }

}
